﻿<!-- announcementAdd -->
<?
global $DB, $sess, $sPOST, $sGET;
include_once "settings.inc.php";

if(isset($_POST))
{
	$sql = "SELECT * FROM " . _MODULE_NAME . " WHERE id=".$sGET['id'];
	$row = $DB->fetchArray($sql);
	if(!is_array($row[0]))
		git("?"._MODULE_NAME.".list");

	$publishOnHomeYES = "";
	$publishOnHomeNO = "";
	if($row[0]['publish_on_homepage'] == 1)
	{
		$publishOnHomeYES = " checked='checked'";
		$publishOnHomeNO = "";
	}
	else
	{
		$publishOnHomeYES = "";
		$publishOnHomeNO = "  checked='checked'";
	}

	if($row[0]['picture'] == "")
		$pictureContent = "<input type=\"file\" name=\"picture\" id=\"picture\" />";
	else
		$pictureContent = "<a href=\"../pictures/" . _MODULE_NAME . "/bigs/" . $row[0]['picture'] . "\" class=\"galeri\"><img src=\"../pictures/" . _MODULE_NAME . "/thumbs/" . $row[0]['picture'] . "\" /></a> <img src=\"images/iconDelete.png\" id=\"" . $row[0]['id'] . "\" class=\"pictureDelete\" title=\"Sil\" />";
}
?>
<style>
	label		{	font-family:Tahoma; font-size:12px; font-weight:bold; text-align:right;	}
	textarea 	{	position:relative; min-height:250px; background:#fff;	}
	.etiket		{	width:150px; min-height:30px; line-height:30px;	}
	.pictureDelete {	cursor: pointer;}
	#pictureContainer > a > img {	border:3px solid #555;}
</style>

<script>
	$(function(){
		$('.pictureDelete').bind("click",function(event){
			if(confirm("Bu duyuruya ait resmi silmek istediğinizden emin misiniz?"))
			{
				var id = $(event.target).attr("id");
				var result = toPost("?<?=_MODULE_NAME;?>.otherProcess","action=1&process=deletePicture&id="+id);
				switch(result)
				{
					case "OK":
						$('#pictureContainer').html("<input type=\"file\" name=\"picture\" id=\"picture\" />");
					break;

					case "ERROR":
						alert("Resim bir hatadan dolayı silinemedi.");
					break;

					default:
						alert(result);
					break;
				}
			}
		});
	});
</script>

<h2>DUYURU GÜNCELLE</h2>
<form method="post" action="?announcements.editProcess" method="POST" enctype="multipart/form-data" >
	<fieldset>
		<!-- <legend>Duyuru Ekleme</legend> -->
		<input type="hidden" name="id" id="id" value="<?=$row[0]['id']?>" />
		<table cellpadding="0" cellspacing="3" border="0" style="width:100%;">
			<tr>
				<td class="right etiket"><label for="title">Duyuru Başlığı: </label></td>
				<td><input class="mf" name="title" id="title" type="text" value="<?=$row[0]['title']?>" /></td>
			</tr>
			<tr>
				<td class="right etiket"><label for="contentx">Duyuru İçeriği: </label></td>
				<td><textarea name="content" id="contentx" class="tinymceMini"><?=$row[0]['content']?></textarea></td>
			</tr>
			<tr>
				<td class="right etiket"><label for="picture">Resim: </label></td>
				<td id="pictureContainer"><?=$pictureContent ?></td>
			</tr>
			<tr>
				<td class="right etiket"><label for="publish_start_date">Yayın Aralığı: </label></td>
				<td><input class="datetime" name="publish_start_date" id="publish_start_date" type="text" value="<? echo datetime($row[0]['publish_start_date'],"date");?>" /> <input class="datetime" name="publish_end_date" id="publish_end_date" type="text" value="<? echo datetime($row[0]['publish_stop_date'], "date");?>" /></td>
			</tr>
			<tr>
				<td class="right etiket"><label for="publish_start_date">Anasayfada Yayınlansın: </label></td>
				<td><input name="publish_on_homepage" id="publish_on_homepage1" type="radio" value="1" <? echo $publishOnHomeYES;?> /> <label for="publish_on_homepage1">Evet</label> &nbsp; <input name="publish_on_homepage" id="publish_on_homepage0" type="radio" value="0" <? echo $publishOnHomeNO;?> /><label for="publish_on_homepage0">Hayır</label></td>
			</tr>
			<tr>
				<td class="etiket">&nbsp;</td>
				<td class="left">
					<input class="button" type="submit" value="Güncelle" />
					<input class="button geri" type="button" value="Geri" />
				</td>
			</tr>
		</table>
	</fieldset>
</form>
<!-- /announcementAdd -->		